FROM node:18-alpine

WORKDIR /app

# 安装 pnpm
RUN npm install -g pnpm && \
    pnpm config set registry https://registry.npmmirror.com

COPY package.json pnpm-lock.yaml ./

# 打印文件，确认 pnpm-lock.yaml 在 COPY 进去了
RUN ls -l

RUN pnpm install --frozen-lockfile

COPY . .

# 打印目录结构方便调试
RUN ls -l

RUN pnpm run build:prod

FROM nginx:alpine

COPY --from=0 /app/dist /usr/share/nginx/html

COPY nginx.conf /etc/nginx/nginx.conf
